package poi;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.text.DateFormat;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


import java.util.ArrayList;
import java.util.List;

/**
 * Created by 佑玉宇 on 2017/3/6.
 */
public class test {
    public static void main(String[] args) {
        ExportExcel<ExcelValue> value = new ExportExcel<ExcelValue>();
        String titles = "日报表";
        String[] headers = {"传感器编号", "垂直偏移", "温度", "湿度", "风力", "磨损"};
        List<ExcelValue> dataset = new ArrayList<ExcelValue>();
        dataset.add(new ExcelValue("1", "3.0", "4.0", "5.0", "0.33", "0.66"));
        dataset.add(new ExcelValue("2", "4.0", "4.0", "5.0", "0.33", "0.33"));
        dataset.add(new ExcelValue("3", "5.0", "4.0", "5.0", "0.33", "0.56"));
        dataset.add(new ExcelValue("4", "6.0", "4.0", "5.0", "0.33", "0.678"));
        dataset.add(new ExcelValue("5", "7.0", "4.0", "5.0", "0.33", "0.646"));
        dataset.add(new ExcelValue("6", "8.0", "4.0", "5.0", "0.33", "0.16"));
        dataset.add(new ExcelValue("7", "3.0", "4.0", "5.0", "0.33", "0.69"));
        Date date=new Date();
        DateFormat format=new SimpleDateFormat("yyyy-MM-dd HHmm");
        String time=format.format(date);
        try {
            FileOutputStream out = new FileOutputStream("D://" +time+ ".xls");
            value.exportExcel(titles,headers, dataset, out);
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();

        }
    }
}
